<?php
/**
 * @subpackage	com_anjolina
 * @copyright	Copyright (C) 2012 Mario Wolf
 * @license		GNU General Public License version 2 or later;
 */

// no direct access
defined('_JEXEC') or die;

// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');

$user		= JFactory::getUser();
$userId		= $user->get('id');
$extension	= $this->escape($this->state->get('filter.extension'));
$listOrder	= $this->escape($this->state->get('list.ordering'));
$listDirn	= $this->escape($this->state->get('list.direction'));
$ordering 	= ($listOrder == 'p.name');
$saveOrder 	= ($listOrder == 'p.name' && $listDirn == 'asc');



if(JDEBUG>0){
	?>
	<h3>
		<?php echo JText::_('COM_ANJOLINA_JDEBUG') ?>
	</h3>
	<?php 
}


?>



<form action="<?php echo JRoute::_('index.php?option=com_anjolina&view=anjolinaplugins');?>" method="post" name="adminForm" id="adminForm">

	<fieldset id="filter-bar">
		<div class="filter-search fltlft">
			<label class="filter-search-lbl" for="filter_search"><?php echo JText::_('JSEARCH_FILTER_LABEL'); ?></label>
			<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" title="<?php echo JText::_('COM_CATEGORIES_ITEMS_SEARCH_FILTER'); ?>" />
			<button type="submit"><?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
			<button type="button" onclick="document.id('filter_search').value='';this.form.submit();"><?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?></button>
		</div>
		</fieldset>
	<div class="clr"> </div>

	<table class="adminlist">
		<thead>
			<tr>
				<th width="1%">
					<input type="checkbox" name="checkall-toggle" value="" title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)" />
				</th>
				<th width="5%">
					<?php echo JHtml::_('grid.sort', 'COM_ANJOLINA_PLUGINS_TITLE', 'p.name', $listDirn, $listOrder); ?>
				</th>
				<th width="15%">
					<?php echo JHtml::_('grid.sort', 'COM_ANJOLINA_PLUGINS_DESC', 'p.desc', $listDirn, $listOrder); ?>
				</th>
				<th width="5%">
					<?php echo JHtml::_('grid.sort', 'COM_ANJOLINA_PLUGINS_ACTIVEXML', 'p.activexml', $listDirn, $listOrder); ?>
				</th>
				<th width="5%">
					<?php echo JHtml::_('grid.sort', 'COM_ANJOLINA_PLUGINS_ACTIVESOAP', 'p.activesoap', $listDirn, $listOrder); ?>
				</th>
				<th width="5%">
					<?php echo JHtml::_('grid.sort', 'COM_ANJOLINA_PLUGINS_ACTIVEJSON', 'p.activejson', $listDirn, $listOrder); ?>
				</th>
				<th width="5%">
					<?php echo JHtml::_('grid.sort',  'COM_ANJOLINA_PLUGINS_VERSION', 'p.version', $listDirn, $listOrder); ?>
				</th>
				<th width="5%" class="nowrap">
					<?php echo JHtml::_('grid.sort', 'COM_ANJOLINA_PLUGINS_AUTHOR', 'p.author', $listDirn, $listOrder); ?>
				</th>
				<th width="1%" class="nowrap">
					<?php echo JHtml::_('grid.sort',  'JGRID_HEADING_ID', 'p.id', $listDirn, $listOrder); ?>
				</th>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="15">
					<?php echo $this->pagination->getListFooter(); ?>
				</td>
			</tr>
		</tfoot>
		<tbody>
			<?php
			$originalOrders = array();
			foreach ($this->items as $i => $item) :

				$canEdit	= $user->authorise('core.edit',			$extension.'.category.'.$item->id);
				$canCheckin	= $user->authorise('core.admin', 'com_checkin') || $item->checked_out == $userId || $item->checked_out == 0;
				$canChange	= $user->authorise('core.edit.state',	$extension.'.category.'.$item->id) && $canCheckin;
			?>
				<tr class="row<?php echo $i % 2; ?>">
					<td class="center">
						<?php echo JHtml::_('grid.id', $i, $item->id); ?>
					</td>
					<td>
						<?php echo $this->escape($item->name); ?>
					</td>
					<td>
						<?php echo $this->escape($item->desc); ?>
					</td>
					<!-- 
					<td class="center">
						<?php echo JHtml::_('jgrid.published', $item->active, $i, 'anjolina.', $canChange)?>
					</td>-->
					<td class="center">
						<?php 
							$validxmlpublish = 0;
							if($item->activexml <> NULL && $item->activexml <> 0){
								$validxmlpublish = 1;
							}
							echo JHtml::_('jgrid.published', $validxmlpublish, $i, 'xml_', $canChange);
						?>
					</td> 
					<td class="center">
						<?php 
							$validsoappublish = 0;
							if($item->activesoap <> NULL && $item->activesoap <> 0){
								$validsoappublish = 1;
							}
							echo JHtml::_('jgrid.published', $validsoappublish, $i, 'soap_', $canChange);
						?>
					</td> 
					<td class="center">
						<?php 
							$validjsonpublish = 0;
							if($item->activejson <> NULL && $item->activejson <> 0){
								$validjsonpublish = 1;
							}
							echo JHtml::_('jgrid.published', $validjsonpublish, $i, 'json_', $canChange);
						?>
					</td> 
					<td class="center">
						<?php echo $this->escape($item->version); ?>
					</td>
					<td class="center">
						<?php echo $this->escape($item->author); ?>
					</td>
					<td class="center">
							<?php echo (int) $item->id; ?>
					</td>
				</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
	<div>
		<input type="hidden" name="extension" value="<?php echo $extension;?>" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
		<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
		<input type="hidden" name="original_order_values" value="<?php echo implode($originalOrders, ','); ?>" />
		<?php echo JHtml::_('form.token'); ?>
	</div>
</form>
